/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package polynomialSimplifier;

/**
 *
 * @author Nathan
 */
public class Number {

  private int coeff;
  private int power;

  public Number() {
    this.coeff = 0;
    this.power = 0;
  }

  public Number(int coeff, int power) {
    this.coeff = coeff;
    this.power = power;
  }

  public Number(Number number) {
    this.coeff = number.getCoeff();
    this.power = number.getPower();
  }

  public int getCoeff() {
    return coeff;
  }

  public void setCoeff(int coeff) {
    this.coeff = coeff;
  }

  public int getPower() {
    return power;
  }

  public void setPower(int power) {
    this.power = power;
  }

  @Override
  public String toString() {
    String result = "";
    if (this.coeff == 0) {
      return result;
    } else if (this.coeff > 0) {
      result = "+ ";
    } else {
      result = "- ";
    }
    result += String.valueOf(Math.abs(this.coeff));
    if (this.power == 0) {
      return result;
    }
    result += "x";
    if (this.power != 1) {
      result += "^" + String.valueOf(this.power);
    }
    result += " ";
    return result;
  }
}
